package org.broadinstitute.hellbender.transformers;

import org.broadinstitute.hellbender.utils.read.ArtificialReadUtils;
import org.broadinstitute.hellbender.utils.read.GATKRead;
import org.broadinstitute.hellbender.GATKBaseTest;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import java.util.Arrays;

public class DUSTReadTransformerTest extends GATKBaseTest {

    @DataProvider(name = "sequenceStrings")
    public Object[][] getSequenceStrings() {
        return new Object[][]{
                {"CGTTTTTCAGTGATTTCTTCATTTTTCAATTCGTCAAGTGGATGTTTCTCATTTTCCATGATTTTCAGTTTTCTTGCCATATTCCACGTCCTACAGTGGAc",
                        "CGNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNAGTTTTCTTGCCATATTCCACGTCCTACAGTGGAc"},

                {"CCCAGGTGGTTTCAAACATTGCCTTGTATGTTGGCTTGGTCTGGATGATGTTTGTTCAGAACCAACGCTTAGCCTGGGTTACCGTAGCTTCTACCCCCGTa",
                        "CCCAGGTGGTTTCAAACATTGCCTTGTATGTTGGCTTGGTCTGGATGATGTTTGTTCAGAACCAACGCTTAGCCTGGGTTACCGTAGCTTCTACCCCCGTa"},

                {"CTCAAGTACAAGCTGATCCAGACCTACAGGGTGATGTCATTAGAGGCACTGATAACACACACACTATGGGGTGGGGGTGGACAGTTCCCCACTGCAATCCg",
                        "CTCAAGTACAAGCTGATCCAGACCTACAGGGTGATGTCATTAGAGGCACTGATAACACACACACTATGGGGTGGGGGTGGACAGTTCCCCACTGCAATCCg"},

                {"GTGTAGCCCCCGTGAATTGGTTCTTCCAAATGCCCCACAAAAACGCGGGATTATCGAATTGCCAGAGGCTACCCCTGTCGGCCAAGCCTTTGATCCAGCCA",
                        "GTGTAGCCCCCGTGAATTGGTTCTTCCAAATGCCCCACAAAAACGCGGGATTATCGAATTGCCAGAGGCTACCCCTGTCGGCCAAGCCTTTGATCCAGCCA"},

                {"ACTTTTGGCTCTCTTTGTCTTTAAGTTTTTTTGTTTGTTTGTTCTTTGTCTAGGTATGGATCTTCTTGAGTTTGTCTCACAAATTTTATCTTACTGGCCAt",
                        "ACTTTTGGCTCTCTTTGTCTTTAAGNNNNNNNGTTTGTTTGTTCTTTGTCTAGGTATGGATCTTCTTGAGTTTGTCTCACAAATTTTATCTTACTGGCCAt"},

                {"CCATATTCCAGGTCCTTCAGTGGGCATTTCTCATTTTTCACGTTTTTTAGTGATTTCGTCATTTTTCAAGTCGTCAAGTGGATGTTTCTCATTTTCCATGA",
                        "CCATATTCCAGGTCCTTCAGTGGGCANNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNCCATGA"},

                {"ACATATTCCAGGTCCTTCAGTGGGCATTTCTCATTTTTCACGTTTTTTAGTGATTTCGTCATTTTTCAAGTCGTCAAGTGGATGTTTCTCATTTTCCATGA",
                        "ACATATTCCAGGTCCTTCAGTGGGCANNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNCCATGA"},

                {"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
                        "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"},

                {"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAN",
                        "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"},

                {"CGTTTTTCAGTGATTTCTTCATTTTTCAATTCGTCAAGTGGATGTTTCTCATTTTCCATGATTTTCAGTTTTCTTGCCATATTCCACGTCCTACAGTGGAC",
                        "CGNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNAGTTTTCTTGCCATATTCCACGTCCTACAGTGGAC"},

                {"GCTATCACTATATCCATCACGCCTGAAATGTACTAATGGGGGGGCAAACGAAACACTACATCAACTCCTTTTTTGATGCAAAAAAGTTCAGATTAACATAT",
                        "GCTATCACTATATCCATCACGCCTGAAATGTACTAATNNNNNNNCAAACGAAACACTACATCAACTCCTTTTTTGATGCAAAAAAGTTCAGATTAACATAT"}
        };
    }

    @Test(dataProvider = "sequenceStrings")
    public void testApply(final String seq_in, final String seq_out) throws Exception {

        final DUSTReadTransformer dustTrans = new DUSTReadTransformer((short) 15, 64, 20.0f);
        final byte[] quals = seq_in.getBytes().clone();
        Arrays.fill(quals, (byte) 'I');
        final GATKRead read_in = ArtificialReadUtils.createArtificialRead(seq_in.getBytes(), quals, "*");
        final GATKRead read_out = dustTrans.apply(read_in);
        Assert.assertEquals(read_out.getBases(), seq_out.getBytes());
    }

}